package com.ruoyi.common.core.utils;

import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;

import java.util.Map;

/**
 * @author : 魔方;
 * @create : 2022/11/12 9:20:51;
 * @description : DistanceUtils--->
 */
public class DistanceUtils {
    public static double Distance(Double sourceLongitude,Double sourceLatitude, Double targetLongitude,Double targetLatitude){
        GlobalCoordinates gpsFrom  = new GlobalCoordinates(sourceLongitude, sourceLatitude);
        GlobalCoordinates gpsTo  = new GlobalCoordinates(targetLongitude, targetLatitude);
        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.Sphere, gpsFrom, gpsTo);

        return geoCurve.getEllipsoidalDistance();
    }
}
